define(function(require, exports, module) {
	var common = require('common');

	// 画面初期加载
	var init = function() {
		$("#userCompanySearchBtn").click(function() {
			common.showModal("查找公司", "sys/popCompanySelect.html", 300, function(subPbox) {
				seajs.use("../static/sys/popCompanySelect.js", function(company) {
					company.init(subPbox);
				});
			}, null, function(returnVal) {
				$("#userCompanySearchBtn").attr("disabled", false);
				$("#userCompany").val(returnVal);
			});
			$(this).attr("disabled", true);
		});
		$("#btnUserClose").click(function() {
			mainPbox.close();
		});
		$("#btnSave").click(function() {
			if ($("#userInfoForm").validate().form()) {
				$("#userInfoForm").submit();
			}
		});
		$("#btnUserList, #btnReturn").click(function() {
			common.ajaxLoadPage($(this).attr("href"));
			return false;
		});

		var rules = {
                userCompany : {
                    required : true
                },
                department : {
                    required : true
                },
                loginId : {
                    required : true
                },
                username : {
                    required : true
                },
                password : {
                    required : true,
                    minlength : 8
                },
                confirmPasswrd : {
                    required : true,
                    equalTo : '#password'
                },
                email : {
                    required : true
                },
                mobile : {
                	digits:true
                }
            };
		common.handleSubmit($("#userInfoForm"), rules);
		/* 控件初始化 */
        $("select").select2();
	}


	return {
		init: init
	}
});